﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ProceduralCity.Textures.Walls;

namespace ProceduralCity.Models.Buildings
{
    abstract class BuildingBase : ModelState
    {
        /// <summary>
        /// Single texture used for all walls.
        /// </summary>
        protected Texture2D wallTexture;
        protected Texture2D roofTexture;

        public BuildingBase()
        { }

        public void SetTextures(Texture2D wallTexture, Texture2D roofTexture)
        {
            this.wallTexture = wallTexture;
            this.roofTexture = roofTexture;
        }

        /// <summary>
        /// Called at draw time to draw the building.
        /// </summary>
        /// <param name="buildingEffect">Effect used to render the building.</param>
        public void Draw(GraphicsDevice device, BasicEffect buildingEffect)
        {
            Matrix world = buildingEffect.World;
            buildingEffect.World = LocalWorld * world;
            DrawInternal(device, buildingEffect);
            buildingEffect.World = world;
        }

        /// <summary>
        /// Called at draw time to draw the building.
        /// </summary>
        /// <param name="buildingEffect">Effect used to render the building.</param>
        protected abstract void DrawInternal(GraphicsDevice device, BasicEffect buildingEffect);
    }
}
